Imports System.Data.Common
Partial Class Presentation_Management_ProjectProgress
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim Sql As String
        Dim Records As DbDataReader
        Dim CountSql As String
        Dim Params(0) As GenParameter

        Page.Title = "Project View"


        If Not Page.IsPostBack Then

            Sql = "Select ProjectID, ProjectName from ProjectMaster WHERE Completed = 0"
            Records = GenHelper.ExecuteReader(Sql, ConfigurationManager.ConnectionStrings.Item("MySqlConnString").ToString())

            dlProjectNames.DataValueField = "ProjectID"
            dlProjectNames.DataTextField = "ProjectName"
            dlProjectNames.DataSource = Records
            dlProjectNames.DataBind()

        End If

        'Code for the pager

        Sql = "SELECT ClientMaster.ClientName, ExecutiveMaster.ExecutiveName, DATE_FORMAT(WorkflowMaster.MeetingDate,'%d/%m/%y') AS 'Meeting Date',ActionMaster.ActionDescription, " & _
          "WorkflowMaster.Details, WorkflowMaster.NextAction, DATE_FORMAT(WorkflowMaster.DateofNextAction,'%d/%m/%y') AS 'Date of Next Action' " & _
        "FROM ActionMaster INNER JOIN (ProjectMaster INNER JOIN (ExecutiveMaster INNER JOIN (ClientMaster INNER JOIN WorkflowMaster ON " & _
        "ClientMaster.ClientID = WorkflowMaster.ClientID) ON ExecutiveMaster.ExecutiveID = WorkflowMaster.ExecutiveID) ON " & _
        "ProjectMaster.ProjectID = WorkflowMaster.ProjectID) ON ActionMaster.ActionID = WorkflowMaster.ActionID " & _
        "WHERE WorkflowMaster.ProjectID = ?ProjectID" & _
        " ORDER BY ClientMaster.ClientName, WorkflowMaster.MeetingDate"

        CountSql = "SELECT COUNT(*)" & _
        " FROM ActionMaster INNER JOIN (ProjectMaster INNER JOIN (ExecutiveMaster INNER JOIN (ClientMaster INNER JOIN WorkflowMaster ON " & _
        "ClientMaster.ClientID = WorkflowMaster.ClientID) ON ExecutiveMaster.ExecutiveID = WorkflowMaster.ExecutiveID) ON " & _
        "ProjectMaster.ProjectID = WorkflowMaster.ProjectID) ON ActionMaster.ActionID = WorkflowMaster.ActionID " & _
        "WHERE WorkflowMaster.ProjectID = ?ProjectID" & _
        " ORDER BY ClientMaster.ClientName, WorkflowMaster.MeetingDate"

        Params(0) = New GenParameter("?ProjectID", dlProjectNames.SelectedValue, Data.DbType.UInt32)

        ProjectProgress.Sql = Sql
        ProjectProgress.CountSql = CountSql
        ProjectProgress.Params = Params
        ProjectProgress.ShowButton = True


    End Sub
End Class
